<template>
  <div class="not-found-container">
    <!-- 错误提示卡片 -->
    <el-card class="error-card">
      <div class="error-content">
        <!-- 错误图标 -->
        <div class="error-icon">
          <el-icon><WarningFilled /></el-icon>
        </div>

        <!-- 错误信息 -->
        <div class="error-info">
          <h1 class="error-code">404</h1>
          <p class="error-message">抱歉，您访问的页面不存在或已被移除</p>
        </div>

        <!-- 操作按钮 -->
        <div class="error-actions">
          <el-button
              type="primary"
              size="large"
              @click="handleGoHome"
          >
            <el-icon><House /></el-icon>
            返回首页
          </el-button>
          <el-button
              size="large"
              @click="handleReLogin"
          >
            <el-icon><RefreshLeft /></el-icon>
            重新登录
          </el-button>
        </div>
      </div>
    </el-card>
  </div>
</template>

<script setup>
import { useRouter } from 'vue-router';
import { WarningFilled, House, RefreshLeft } from '@element-plus/icons-vue';
import { ElMessage } from 'element-plus';

const router = useRouter();

// 返回首页
const handleGoHome = () => {
  router.push('/');
};

// 重新登录（清除缓存并跳转登录页）
const handleReLogin = () => {
  localStorage.removeItem('user');
  localStorage.removeItem('viewType');
  router.push('/login');
  ElMessage.info('请重新登录');
};
</script>

<style scoped>
.not-found-container {
  min-height: 100vh;
  background-color: #f5f7fa;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.error-card {
  width: 100%;
  max-width: 600px;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.error-content {
  padding: 40px 20px;
  text-align: center;
}

.error-icon {
  font-size: 80px;
  color: #ff7d00; /* 警告色 */
  margin-bottom: 20px;
}

.error-code {
  font-size: 60px;
  font-weight: bold;
  color: #333;
  margin: 0 0 10px 0;
}

.error-message {
  font-size: 18px;
  color: #666;
  margin: 0 0 30px 0;
}

.error-actions {
  display: flex;
  gap: 20px;
  justify-content: center;
}
</style>